MenuHostHelper

Helper class for implementing MenuHost. This class should be used to implement the MenuHost functions. i.e.:

class ExampleComponent : MenuHost {

    private val menuHostHelper = MenuHostHelper{ invalidateMenu() }

    override fun invalidateMenu() { … }

    override fun addMenuProvider(provider: MenuProvider, owner: LifecycleOwner) {
        menuHostHelper.addMenuProvider(provider, owner)
    }

    // Override remaining MenuHost methods in similar fashion
}

Constructors

Link copied to clipboard
constructor(@NonNull onInvalidateMenuCallback: Runnable)
Construct a new MenuHostHelper.

Functions

Link copied to clipboard
open fun addMenuProvider(@NonNull provider: MenuProvider)
Adds the given MenuProvider to the helper.
Adds the given MenuProvider to the helper once the given LifecycleOwner reaches the given Lifecycle.State.
Link copied to clipboard
open fun onCreateMenu(@NonNull menu: Menu, @NonNull menuInflater: MenuInflater)
Inflates the entire Menu, which will include all MenuItems provided by all current MenuProviders.
Link copied to clipboard
open fun onMenuClosed(@NonNull menu: Menu)
Called when the given Menu, which was provided by one of the current MenuProviders, is closed.
Link copied to clipboard
Called whenever one of the menu items from any of the current MenuProviders is selected.
Link copied to clipboard
open fun onPrepareMenu(@NonNull menu: Menu)
Called right before the given Menu, which was provided by one of the current MenuProviders, is to be shown.
Link copied to clipboard
Removes the given MenuProvider from the helper.